package com.ruoyi.tester.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.tester.domain.TaskCallLogOut;
import com.ruoyi.tester.executor.expression.ExpressionContainer;
import com.ruoyi.tester.service.ITesterExecutorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author SongJun
 * @description TODO:
 * @date 2022/4/15 10:43
 */
@Controller
@RequestMapping("/tester/executor")
public class TesterExecutorController extends BaseController {


    @Autowired
    ITesterExecutorService testerExecutorService;

    @GetMapping("/task")
    @ResponseBody
    public AjaxResult executeTesterTask(Long taskId){
        testerExecutorService.executeTesterTask(taskId);
        return toAjax(true);
    }

    @ApiOperation("查看任务日志")
    @GetMapping("/task/log")
    @ResponseBody
    public TableDataInfo getTaskLog()
    {
        startPage();
        List<TaskCallLogOut> list = testerExecutorService.getTaskLog();
        return getDataTable(list);
    }
}
